<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta name="keywords" content="">
		<meta name="description" content="">
		<title>打包管理</title>
		<link rel="shortcut icon" href="favicon.ico">
		<link href="../static/css/bootstrap.min.css" rel="stylesheet" />
		<link href="../static/css/font-awesome.min.css" rel="stylesheet" />
		<!-- bootstrap-table 表格插件样式 -->
		<link href="../static/ajax/libs/bootstrap-table/bootstrap-table.min.css" rel="stylesheet" />
		<link href="../static/css/animate.css" rel="stylesheet" />
		<link href="../static/css/style.css" rel="stylesheet" />
		<link href="../static/ruoyi/css/ry-ui.css" rel="stylesheet" />
		

		<link href="../static/ajax/libs/jquery-layout/jquery.layout-latest.css" rel="stylesheet" />
		<style>
			.echarts{
				height: 300px !important;
			}

		</style>
		
	</head>
	<body class="gray-bg">

		<div class="container-div">

			<div class="row">
				<div class="col-sm-12">

					<div class="ibox float-e-margins">
						<div class="ibox-title">
							<div class="pull-left">
								<h5>t2019101402传输设备上实时数据</h5>
							</div>
							<div class="pull-right btn-group btn-group-sm" role="group">
								<button class="btn btn-danger" type="button">急停</button>
								<button class="btn btn-info" type="button">联机</button>
								<button class="btn btn-danger" type="button">断开</button>
							</div>
						</div>
						<div class="ibox-content">

							<div class="row">
								<div class="col-sm-8">
									<div class="echarts" id="pack">

									</div>
								</div>
								<div class="col-sm-4">

									<div class="panel panel-info">
										<div class="panel-heading">
											参数标准
										</div>
										<div class="panel-body">

											<div class="row">
												<div class="col-sm-6 b-r">
													<div class="form-group">
														<label>风扇转速:</label>
														<label id="axlettree_speed_label"></label>
													</div>

												</div>
												<div class="col-sm-6">
													<div class="form-group">
														<label>轮轴转速:</label>
														<label id="blower_speed_label"></label>
													</div>
												</div>
											</div>

										</div>

									</div>

									<div class="panel panel-danger">
										<div class="panel-heading">
											参数调整
										</div>
										<div class="panel-body">

											<div class="row">
												<div class="col-sm-6 b-r">
													<div class="form-group">
														<label>风扇转速</label>
														<input type="text" class="form-control" id="axlettree_speed">
													</div>
													<div class="form-group">
														<input type="reset" class="form-control" value="重置">
													</div>
												</div>
												<div class="col-sm-6 b-r">
													<div class="form-group">
														<label>轮轴转速</label>
														<input type="text" class="form-control" id="blower_speed">
													</div>
													<div class="form-group">
														<input type="button" class="form-control" value="调整" onclick="updateTranStandard()">
													</div>

												</div>
											</div>


										</div>

									</div>

								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

		<script src="../static/js/jquery.min.js"></script>
		<script src="../static/js/bootstrap.min.js"></script>
		<!-- bootstrap-table 表格插件 -->
		<script src="../static/ajax/libs/bootstrap-table/bootstrap-table.min.js"></script>
		<script src="../static/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
		<script src="../static/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js"></script>
		<script src="../static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.min.js"></script>
		<script src="../static/ajax/libs/bootstrap-table/extensions/columns/bootstrap-table-fixed-columns.js"></script>
		<!-- jquery-validate 表单验证插件 -->
		<script src="../static/ajax/libs/validate/jquery.validate.min.js"></script>
		<script src="../static/ajax/libs/validate/messages_zh.min.js"></script>
		<script src="../static/ajax/libs/validate/jquery.validate.extend.js"></script>
		<!-- jquery-validate 表单树插件 -->
		<script src="../static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js"></script>

		<!-- 遮罩层 -->
		<script src="../static/ajax/libs/blockUI/jquery.blockUI.js"></script>
		<script src="../static/ajax/libs/iCheck/icheck.min.js"></script>
		<script src="../static/ajax/libs/layer/layer.min.js"></script>
		<script src="../static/ajax/libs/layui/layui.js"></script>
		<script src="../static/ruoyi/js/common.js?v=4.0.0"></script>
		<script src="../static/ruoyi/js/ry-ui.js?v=4.0.0"></script>

		<!--Echarts -->
		<script src="../static/ajax/libs/report/echarts/echarts-all.js"></script>
		<script src="../static/ruoyi/controller.js"></script>

		<script src="../static/ajax/libs/jquery-layout/jquery.layout-latest.js"></script>

		<script>
            /**
             * 传输数据：重量
             */
                // 基于准备好的dom，初始化echarts实例
            let packChart = echarts.init(document.getElementById("pack"));  //根据ID获取chart

			let time = $.echarts.time;

            let packoption = $.echarts.getDoubleLineOption("t2019101401传输设备实时数据",['风扇转速','轮轴转速']); //得到option

            $.echarts.setChartInterval(pack,time);  //开启定时器，执行指定函数f

            /**
             * 进行数据模拟函数，并将数据动态写入指定的option
             */
            function pack() {
                let axisData = (new Date()).toLocaleTimeString().replace(/^\D*/, '');
                
                let data_1 = Math.round(Math.random() * 300);
                let data_2 = Math.round(Math.random() * 300);

                packoption = $.echarts.setDynamicData(packoption,axisData,data_1,data_2);

                packChart.setOption(packoption);
            }
            
            
            function getRootPath(){
        		let href = window.document.location.href;
        		let pathName = window.document.location.pathname;
        		let index = href.indexOf(pathName);
        		let localhost = href.substring(0,index);
        		let project = pathName.substring(0,(pathName.substr(1).indexOf('/'))+1);
        			
        		return (localhost+project);
        	}
        	
        	let rootPath = getRootPath();
        	
            function updateTranStandard(){
            	if(tranStandard.tranCheck()){
            		let axlettreeSpeed = $("#axlettree_speed").val();
            		let blowerSpeed=$("#blower_speed").val();
            		let deviceId="t2019101402";
            		$.ajax({
                        url: rootPath+"/production/transport/updateTranStandard.do",
                        type:"POST",
                        dataType:"json",
                        data : {
                        	axlettreeSpeed:axlettreeSpeed,
                        	blowerSpeed:blowerSpeed,
                        	deviceId:deviceId
                        },
                        success : function (response) {
                        	if(response.Result=="failed"){
                        		layer.alert(response.message, {icon: 3, title:'提示'});
                        	}else{
                        		layer.alert(response.message, {icon: 1, title:'提示'},function(){
                            		window.location.reload();
                            	}); 
                        	}
                        }
                    });
            	}
            }
            
            let tranStandard = {
                    tranCheck : function () {
                        let bloweeSpeed = $("#blower_speed").val();
                        let axlettreeSpeed = $("#axlettree_speed").val();
                        if(axlettreeSpeed==''||axlettreeSpeed==null){
                        	 $.modal.msg("风扇转速不能为空");
                             return false;
                        }
                        if(bloweeSpeed == '' || bloweeSpeed == null){
                            $.modal.msg("轮轴转速不能为空");
                            return false;
                        }
                        return true;
                    }
                }
            
           function getTranStandard() {
            	let deviceId="t2019101402";
        		$.ajax({
        			url : rootPath + "/production/transport/getTranStandard.do",
        			type : "POST",
        			dataType:"json",
        			data : {
        				deviceId:deviceId
        			},
        			success : function(response) {
        				if(response.RESUTL === "failed"){
                        	$.modal.alert(response.message);
                        }else{
                        	$("#axlettree_speed_label").html(response.TransportStandardVo.axlettreeSpeed);
                        	$("#blower_speed_label").html(response.TransportStandardVo.blowerSpeed);
                        }
        			}
        		});
            }
            
          $(function(){
        	  getTranStandard();
          });
		</script>
	</body>
</html>
